<?php
namespace app\api\controller;
use think\Controller;
use app\api\model\Article as ArticleModel;

class Article extends Controller
{
    /**
     * 文章列表
     */
    public function ArtList()
    {
        $article= new ArticleModel();
        $cate_id = input('param.cate_id');
        $page = input('param.page');
        $listRows = input('param.listRows');
        $data = $article->ArtList($cate_id,$page,$listRows);
        if ($data) {
            return json(['data'=>$data,'code'=>0,'message'=>'查询成功']);
        } else {
            return json(['data'=>$data,'code'=>1,'message'=>'无结果']);
        }
    }

    /**
     * 取分类
     */
    public function selCateAll()
    {
        $article= new ArticleModel();
        $data = $article->selCateAll();
        if ($data) {
            return json(['data'=>$data,'code'=>0,'message'=>'查询成功']);
        } else {
            return json(['data'=>$data,'code'=>1,'message'=>'无结果']);
        }
    }

    /**
     * 取文章内容
     */
    public function getArtById()
    {
        $article= new ArticleModel();
        $article_id = input('param.article_id');
        $data = $article->getArtById($article_id);
        if ($data) {
            return json(['data'=>$data,'code'=>0,'message'=>'查询成功']);
        } else {
            return json(['data'=>$data,'code'=>1,'message'=>'无结果']);
        }
    }
}
